home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 2 / Atari Mega Archive CD - Volume 2.iso / minix / up1510b.tgz / up1510b / src / lib / ansi / memset.c < prev    next >
C/C++ Source or Header  |  1990-07-19  |  561b  |  31 lines

  1. #include <lib.h>
  2. /* memset - set bytes
  3.  *
  4.  * CHARBITS should be defined only if the compiler lacks "unsigned char".
  5.  * It should be a mask, e.g. 0377 for an 8-bit machine.
  6.  */
  7.  
  8. #include <string.h>
  9.  
  10. #ifndef CHARBITS
  11. #    define    UNSCHAR(c)    ((unsigned char)(c))
  12. #else
  13. #    define    UNSCHAR(c)    ((c)&CHARBITS)
  14. #endif
  15.  
  16. void *memset(s, ucharfill, size)
  17. _VOIDSTAR s;
  18. register int ucharfill;
  19. size_t size;
  20. {
  21.   register char *scan;
  22.   register size_t n;
  23.   register int uc;
  24.  
  25.   scan = (char *) s;
  26.   uc = UNSCHAR(ucharfill);
  27.   for (n = size; n > 0; n--) *scan++ = uc;
  28.  
  29.   return(s);
  30. }
  31.